prepare-root: remember to remove /sysroot.tmp
authorBenjamin Gilbert <bgilbert@redhat.com>
Fri, 13 Sep 2019 06:37:01 +0000 (02:37 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 13 Sep 2019 12:40:57 +0000 (12:40 +0000)
Without this, rerunning ostree-prepare-root will fail in mkdir()
because /sysroot.tmp already exists, which complicates debugging from
the dracut emergency shell.

Closes: #1919
Approved by: cgwalters

src/switchroot/ostree-prepare-root.c

index 3d6e78336943e60858b6abbd313d11946d47143c..33c46ff45c7c588dc831ef420e30a51c9944f8e3 100644 (file)
@@ -273,6 +273,9 @@ main(int argc, char *argv[])
 
       if (mount (".", root_mountpoint, NULL, MS_MOVE, NULL) < 0)
         err (EXIT_FAILURE, "failed to MS_MOVE %s to %s", deploy_path, root_mountpoint);
+
+      if (rmdir ("/sysroot.tmp") < 0)
+        err (EXIT_FAILURE, "couldn't remove temporary sysroot /sysroot.tmp");
     }
 
   /* The /sysroot mount needs to be private to avoid having a mount for e.g. /var/cache